package com.whq.thrift.api.kafka.requestlog.db;

import java.util.Date;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;


public interface RequestLogMapper {
	
	@Insert("INSERT INTO t_request_log_#{tableSeq} "
			+ " (time, phone, mid, snda_id, ip, device_id, network, mac_address, flow_id, request_params, " 
			+ " verify_code, create_time, method, app_version, os_type, os_version, device_model, cost, result_code, "
			+ " extend1, extend2, extend3, extend4, extend5) "
			+ " VALUES "
			+ " (#{timestamp}, #{phone}, #{mid}, #{sndaId}, #{host}, #{devicedId}, #{network}, #{macAddress}, #{flowId}, #{requestParams}, " 
			+ " #{verifyCode}, #{createTime}, #{api}, #{appVersion}, #{osType}, #{osVersion}, #{deviceModel}, #{cost}, #{resultCode}, "
			+ " #{extend1}, #{extend2}, #{extend3}, #{extend4}, #{extend5}) ")
	@Options(useGeneratedKeys = true, keyProperty = "id")
	public void addRecord(RequestLog requestLog);
	
	@Delete("delete from t_request_log_#{tableSeq} where time<#{timestamp}")
	public void delRecordsByTimeBefore(@Param("tableSeq") int tableSeq, @Param("timestamp") Date timestamp);

}
